package exam.pdd.S4;

import java.util.*;

public class Main {

    public static int T;
    public static int n;
    public static int k;
    public static String s;
    public static int[] cnt = new int[26];


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        T = sc.nextInt();
        for (int i = 0; i < T; i++) {
            n = sc.nextInt();
            k = sc.nextInt();
            sc.nextLine();
            s = sc.nextLine();
            Arrays.fill(cnt, 0);
            for (int j = 0; j < s.length(); j++) {
                cnt[s.charAt(j)-'a']++;
            }
            solution();
        }
    }

    public static void solution() {
        if (n % k != 0) {
            System.out.println("-1");
            return;
        }
        if (isBeauty()) {
            System.out.println(s);
        }
    }

    public static boolean isBeauty() {
        for (int i=0; i<26; ++i) {
            if (cnt[i] % k != 0)
                return false;
        }
        return true;
    }
}